package org.openmore.opc.service;


import io.swagger.annotations.ApiParam;
import org.openmore.opc.dto.BaseResponse;
import org.openmore.opc.service.feignFactory.WechatMiniServiceFeignFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

@Service
@FeignClient(value = "openmore-third-platform", fallbackFactory = WechatMiniServiceFeignFactory.class)
public interface WechatMiniService {

    /**小程序登录接口*/
    @GetMapping(value = "/api/wechatMiniapp/{tenantId}/login/{code}")
    BaseResponse getJscodeSessionInfo(@PathVariable @ApiParam(name = "应用ID") String tenantId,
                                      @PathVariable @ApiParam(name = "微信code") String code);
    /**小程序登录后获取用户身份信息*/
    @GetMapping(value = "/api/wechatMiniapp/{tenantId}/info")
    BaseResponse getJscodeSessionInfo(@PathVariable @ApiParam(name = "应用ID") String tenantId,
                                      @RequestParam() @ApiParam("sessionKey")String sessionKey,
                                      @RequestParam() @ApiParam("signature")String signature,
                                      @RequestParam() @ApiParam("rawData")String rawData,
                                      @RequestParam() @ApiParam("encryptedData")String encryptedData,
                                      @RequestParam() @ApiParam("iv")String iv);

    /**微信公众号获取授权信息*/
    @GetMapping(value = "/api/wechatMp/{tenantId}/greet")
    BaseResponse greetUser(@PathVariable @ApiParam(name = "应用ID") String tenantId,
                           @PathVariable @ApiParam(name = "微信code") String code);

    /**微信开放平台跳转请求授权*/
    @GetMapping(value = "/api/wechatOpen/{tenantId}/gotoAuthUrl")
    BaseResponse gotoAuthUrl(@PathVariable @RequestParam(name = "应用ID") String tenantId);

    /**微信开放平台跳转请求授权*/
    @GetMapping(value = "/api/wechatOpen/{tenantId}/authGet")
    BaseResponse gotoPreAuthUrl(@PathVariable @RequestParam(name = "应用ID") String tenantId);

    /**微信开放平台获取授权信息*/
    @GetMapping(value = "/api/wechatOpen/{tenantId}/jump/{authorizationCode}")
    BaseResponse jumpInfo(@PathVariable @RequestParam(name = "应用ID") String tenantId,
                          @PathVariable("authorizationCode") @ApiParam("authorizationCode")String authorizationCode);
    /**微信开放平台获取授权方基本信息*/
    @GetMapping(value = "/api/wechatOpen/{tenantId}/authorInfo")
    BaseResponse getAuthorizerInfo(@PathVariable @RequestParam(name = "应用ID") String tenantId);
}
